package com.item.yxlottery.yxlottery.utils;

/*
 *------------------------------
 * @创建者      Administrator
 * @创建时间    2016/12/17 16:47
 * @文件描述    统计注数帮助类
 *------------------------------
 */

import java.util.ArrayList;

public class CountUtil {

    /* 结算注数 */
    public static long count(ArrayList redSelsectorBarList, ArrayList blueSelsectorBarList) {
        long redC = (int) (factorial(redSelsectorBarList.size()) / (factorial(6) * factorial(redSelsectorBarList.size() - 6)));
        int blueC = blueSelsectorBarList.size();
        return redC * blueC;
    }

    /* 结算注数 */
    public static long count(int redSelsectorBarListSize, int blueSelsectorBarListSize) {
        long redC = (int) (factorial(redSelsectorBarListSize) / (factorial(6) * factorial(redSelsectorBarListSize - 6)));
        int blueC = blueSelsectorBarListSize;
        return redC * blueC;
    }

    /* 结算num的阶乘 */
    private static long factorial(int num) {
        if (num > 1) {
            return num * factorial(num - 1);
        } else if (num == 1 | num == 0) {
            return 1;
        } else {
            throw new IllegalArgumentException("num >= 0");
        }
    }
}
